<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/29
 * Time: 23:08
 */

include_once 'redis.php';

$param = $_GET;//获取请求数据

$url = $_SERVER['HTTP_REFERER'];//跳转url

if (empty($param['uid'])) {
    notice('缺少uid参数');
}

if (!empty($param['type']) && $param['type'] == 'cancel') {
    $ret = $redis->zRem("{$userInfo['uid']}:follow", $param['uid']);// 取消关注数据
    $retTwo = $redis->zRem("{$param['uid']}:followed", $userInfo['uid']);// 取消被关注数据

    if ($ret === 1 && $retTwo === 1) {
        notice('取消关注成功');
    } else {
        notice('取消关注失败');
    }
} else {
    $ret = $redis->zAdd("{$userInfo['uid']}:follow", time(), $param['uid']);// 添加关注数据
    $retTwo = $redis->zAdd("{$param['uid']}:followed", time(), $userInfo['uid']);// 添加被关注数据

    if ($ret === 1 && $retTwo === 1) {
        notice('关注成功');
    } else {
        notice('关注失败');
    }
}
?>